/*
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef MCPY_EXCEPTION_H
#define MCPY_EXCEPTION_H

#include <mc/exception.h>
#include <string>

namespace mcpy {

/**
 * @brief mcpy 异常代码枚举
 *
 * 扩展 mc::exception_code，添加 Python 特定的异常类型
 */
enum mcpy_exception_code {
    value_error_code           = 1000, // ValueError - 值错误
    type_error_code            = 1001, // TypeError - 类型错误
    index_error_code           = 1002, // IndexError - 索引错误
    key_error_code             = 1003, // KeyError - 键错误
    attribute_error_code       = 1004, // AttributeError - 属性错误
    name_error_code            = 1005, // NameError - 名称错误
    zero_division_error_code   = 1006, // ZeroDivisionError - 除零错误
    overflow_error_code        = 1007, // OverflowError - 溢出错误
    runtime_error_code         = 1008, // RuntimeError - 运行时错误
    not_implemented_error_code = 1009, // NotImplementedError - 未实现错误
    stop_iteration_code        = 1010, // StopIteration - 停止迭代
};

// Python ValueError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(value_error, value_error_code, "ValueError", mc::exception);

// Python TypeError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(type_error, type_error_code, "TypeError", mc::exception);

// Python IndexError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(index_error, index_error_code, "IndexError", mc::exception);

// Python KeyError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(key_error, key_error_code, "KeyError", mc::exception);

// Python AttributeError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(attribute_error, attribute_error_code, "AttributeError", mc::exception);

// Python NameError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(name_error, name_error_code, "NameError", mc::exception);

// Python ZeroDivisionError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(zero_division_error, zero_division_error_code, "ZeroDivisionError", mc::exception);

// Python OverflowError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(overflow_error, overflow_error_code, "OverflowError", mc::exception);

// Python RuntimeError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(runtime_error, runtime_error_code, "RuntimeError", mc::exception);

// Python NotImplementedError 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(not_implemented_error, not_implemented_error_code, "NotImplementedError", mc::exception);

// Python StopIteration 异常
MC_DECLARE_EXCEPTION_CLASS_BASE(stop_iteration, stop_iteration_code, "StopIteration", mc::exception);

} // namespace mcpy

#endif // MCPY_EXCEPTION_H
